package cn.sail.shop3.api.filter;

import javax.servlet.*;
import java.io.IOException;

//@WebFilter("/*")
public class EncoderFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        String name=request.getParameter("name");
//        name=new String(name.getBytes("ISO8859-1"),"UTF-8");
        //请求编码
        servletRequest.setCharacterEncoding("utf-8");
        //返回结果设置编码
        servletResponse.setContentType("text/html;charset=UTF-8");
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
